<?php
/**
	CakePHP Filter Plugin

	Copyright (C) 2009-3827 dr. Hannibal Lecter / lecterror
	<http://lecterror.com/>

	Multi-licensed under:
		MPL <http://www.mozilla.org/MPL/MPL-1.1.html>
		LGPL <http://www.gnu.org/licenses/lgpl.html>
		GPL <http://www.gnu.org/licenses/gpl.html>
*/

if (isset($viewFilterParams))
{
	
	foreach ($viewFilterParams as $field)
	{
		
		if($field['options']['type']!='multicheckbox'){
			if(empty($includeFields))
			{
				echo $this->Form->input($field['name'], $field['options']);
			}
			else
			{
				if (in_array($field['name'], $includeFields))
				{
					echo $this->Form->input($field['name'], $field['options']);
				}
			}
		} else {
			echo "<div class='input multicheckbox'>";
				echo "<fieldset>";
					echo "<legend>".$field['options']['label']."</legend>";
						foreach($field['options']['options'] as $key => $option){
						
							$nome = explode('.', $field['name']);
							
							if($this->data[$nome[0]][$nome[1]][$key] != 0){
								$check = true;
							}else {
								$check = false;
							}
							
							echo $this->Form->input($field['name'], array('label'=>$option, 'value'=>$key, 'type'=>'checkbox', 'name'=>'data['.$nome[0].']['.$nome[1].']['.$key.']', 'checked'=>$check));
							
						}
				echo "</fieldset>";
			echo "</div>";
		}
	}
}
